<?php

class Bus_Form_Bus extends Zend_Form
{
    public function  __construct() {
        parent::__construct();

        $this->setAction(BASE_URL . '/bus/bus/save');
        $this->setAttrib('id', 'form_bus');

        $this->addElement('hidden', 'bus_pid');

        $busName = new Zend_Form_Element_Text(array(
            'name' => 'bus_name',
            'id' => 'bus_name',
            'label' => 'Bus name',
            'required' => true
        ));
        $this->addElement($busName);

        $busType = new Zend_Form_Element_Select('bus_type_sid', array(
            'id' => 'bus_type_sid',
            'label' => 'Bus type',
            'required' => true
        ));
        $model = new Bus_Model_Type();
        $rows = $model->fetchAll();
        foreach ($rows as $row) {
            $busType->addMultiOption($row->bus_type_pid, $row->type_name);
        }
        $this->addElement($busType);

        $this->addElement('textarea', 'bus_routes', array(
            'label' => 'Routes',
            'class' => 'hidden'
        ));

        $this->addElement(new Zend_Form_Element_Submit('save', array(
            'label' => 'Save'
        )));
        $this->addElement(new Zend_Form_Element_Button('bus_delete', array(
            'label' => 'Delete'
        )));
        $this->addElement(new Zend_Form_Element_Button('cancel', array(
            'label' => 'Cancel',
            'id' => 'form_bus_cancel'
        )));
    }
}